package com.qf.mq.listener;

import com.qf.events.DirtyWorkdsChangeEvents;
import com.qianfeng.smsplatform.common.constants.RabbitMqConsants;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/*
 * @Data: 2021/7/16 16:32
 * */
@Component
public class DirtyWorkdsChangeListener {

    private ApplicationContext context;


    @Autowired
    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    @StreamListener(RabbitMqConsants.TOPIC_DIRTYWORDS_UPDATE)
    public void s(String msg){
        System.out.println("敏感词发过来的消息是"+msg);

        context.publishEvent(new DirtyWorkdsChangeEvents() );
    }

}
